<?php


namespace app\test\controller;


use function PHPSTORM_META\type;
use think\Controller;
use app\test\model\User;
use think\Db;

class Index extends Controller
{
    public function index()
    {

        //分页
        //获取分页要调用查询类中的paginate(num)方法
        //每页显示5条
        $data = User::order('id', 'desc')->paginate(20);
        $this->assign('data', $data);

        $this->assign('title', '测试数据');
        return $this->fetch();
    }

    public function up()
    {
        $data = Db::name('user')->where('id', '>', 2700)->select();
//        dump($data);exit;
        for ($i = 0; $i < count($data); $i++) {
            $data[$i]['name'] = '小爱' . rand(1, 1000);
            $r = Db::connect('db_local')->name('user')->data($data[$i])->update();
            dump($r);
        }


    }

    function delNoMobile(){
       $r =  User::whereNull('mobile')->delete();
       dump($r);
    }

    function del(){
        $r = User::where('name','like','%石博華111%')->delete();
        dump($r);
    }


}